﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Website
{
    public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Files.Count == 0)
                return;
            Request.Files[0].SaveAs(getDestinationDirectory());
        }

        private string getDestinationDirectory()
        {
            //Vendor_Visit_XMissionStructures
            string _destinationDirectory = Server.MapPath("");
            switch(Request.QueryString["C"])
            {
                case "DEV":
                    _destinationDirectory += "\\..\\..\\DEV\\IMAGES\\";
                    break;
                case "BETA":
                    _destinationDirectory += "\\..\\..\\BETA\\IMAGES\\";
                    break;
            }
            DirectoryInfo _destinationDirectoryInfo = new DirectoryInfo(_destinationDirectory);
            _destinationDirectoryInfo = _destinationDirectoryInfo.CreateSubdirectory(Request.QueryString["T"]);
            _destinationDirectoryInfo = _destinationDirectoryInfo.CreateSubdirectory(Request.QueryString["F"]);
            return _destinationDirectoryInfo.FullName + "\\" + Request.QueryString["FI"];
        }

    }
}
